#include "station.h"

//Every station must have a Callsign, point, and pixmap
Station::Station(QString Callsign, QPixmap icon, QPointF *location) : QGraphicsPixmapItem()
{
    this->name = Callsign;
    this->setPixmap(icon);
    QPointF pixLocation = ConvertPixToLatLon(location);

    this->setX(pixLocation.x());
    this->setY(pixLocation.y());
}

QPointF Station::ConvertPixToLatLon(QPointF *latlon)
{
    //Map is 3600 X 1800.  Each 10 pixels horizontal is a new longitude. each 10 pixels vertical is a new latitude
    //This is assuming that at the exact center of the map is the true lat-lon point (0,0)
    //Each Icon is 20x20 so to draw directly on top of each point you must offset each axis by 10.
    qreal x = ((latlon->x() * 10) + 1800 - 10); //Plus half the map size for offset.
    qreal y = ((latlon->y() * -10) + 900 - 10);  //Again offset for map size. Multiply by -10 since the pixel's grow downward

    QPointF pixCoords;
    pixCoords.setX(x);
    pixCoords.setY(y);

    return pixCoords;
}
